#pragma once
#include"hashtable.h"
using namespace OpenHash;
template<class K, class V, class HF = HashFunc<K>>
class unordered_map
{
	struct MapKeyOfT {const K& operator()(const pair<K, V>& kv) { return kv.first; } };
public:
	typedef typename HashBucket<K, pair<K, V>, MapKeyOfT, HF>::Iterator iterator;
	iterator begin() { return _hb.begin(); }
	iterator end() { return _hb.end(); }
	iterator find(const K& key) { return _hb.Find(key); }
	bool erase(const K& key) { return _hb.Erase(key); }
	pair<iterator, bool> insert(const pair<K, V>& kv) { return _hb.Insert(kv); }
	V& operator[](const K& key)
	{
		pair<iterator, bool> ret = insert(make_pair(key, V()));
		return ret.first->second;
	}
private:
	HashBucket<K, pair<K, V>, MapKeyOfT, HF> _hb;
};

